﻿/*****************************************************************//**
 * @file    VAOneXMLAdaptorMaterials.h
 * @brief   VAOne读写材料适配器
 *
 * @author  lilongyuan (lilongyuan@diso.cn)
 * @date    2025-02-24
 *********************************************************************/
#ifndef VAONEXMLADAPTORMATERIALS_H
#define VAONEXMLADAPTORMATERIALS_H

#include "FITKAbstractVAOneXMLAdaptor.h"

namespace Acoustics
{
    class FITKAcousticsAbsMaterial;
}

namespace IO
{
    /**
     * @brief   VAOne读写材料适配器
     * @author  lilongyuan (lilongyuan@diso.cn)
     * @date    2025-02-24
     */
    class FITKVAOneXMLIOAPI VAOneXMLAdaptorMaterials : public FITKAbstractVAOneXMLAdaptor
    {
        FITKCLASS(IO, VAOneXMLAdaptorMaterials);
    public:
        /**
         * @brief   构造函数
         * @author  lilongyuan (lilongyuan@diso.cn)
         * @date    2025-02-24
         */
        explicit VAOneXMLAdaptorMaterials() = default;
        /**
         * @brief   析构函数
         * @author  lilongyuan (lilongyuan@diso.cn)
         * @date    2025-02-24
         */
        ~VAOneXMLAdaptorMaterials() = default;
        /**
         * @brief   适配器读数据
         * @return  是否执行成功
         * @author  lilongyuan (lilongyuan@diso.cn)
         * @date    2025-02-24
         */
        bool adaptR() override;
        /**
         * @brief   适配器写数据
         * @return  是否执行成功
         * @author  lilongyuan (lilongyuan@diso.cn)
         * @date    2025-02-24
         */
        bool adaptW() override;
    private:
        /**
         * @brief     读取流体材料数据
         * @param[i]  node Fluid节点
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-25
         */
        bool readFluid(rapidxml::xml_node<char>* node);
        /**
         * @brief     读取泡沫材料数据
         * @param[i]  node Foam节点
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-25
         */
        bool readFoam(rapidxml::xml_node<char>* node);
        /**
         * @brief     读取纤维材料数据
         * @param[i]  node Fiber节点
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-25
         */
        bool readFiber(rapidxml::xml_node<char>* node);
        /**
         * @brief     读取各向同性固体材料数据
         * @param[i]  node Isosolid节点
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-25
         */
        bool readIsosolid(rapidxml::xml_node<char>* node);
        /**
         * @brief     读取粘弹性材料数据
         * @param[i]  node ViscoElasticMaterial节点
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-25
         */
        bool readViscoElasticMaterial(rapidxml::xml_node<char>* node);
    private:
        /**
         * @brief     写出流体材料数据
         * @param[i]  node Materials节点
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-25
         */
        bool writeFluid(rapidxml::xml_node<char>* node);
        /**
         * @brief     写出泡沫材料数据
         * @param[i]  node Materials节点
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-25
         */
        bool writeFoam(rapidxml::xml_node<char>* node);
        /**
         * @brief     写出纤维材料数据
         * @param[i]  node Materials节点
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-25
         */
        bool writeFiber(rapidxml::xml_node<char>* node);
        /**
         * @brief     写出各向同性固体材料数据
         * @param[i]  node Materials节点
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-25
         */
        bool writeIsosolid(rapidxml::xml_node<char>* node);
        /**
         * @brief     写出粘弹性材料数据
         * @param[i]  node Materials节点
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-25
         */
        bool writeViscoElasticMaterial(rapidxml::xml_node<char>* node);
    private:
        /**
         * @brief     读取基础属性数据
         * @param[i]  node 节点，data 材料派生类数据对象
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-24
         */
        bool readBasicAttribute(rapidxml::xml_node<char>* node, Acoustics::FITKAcousticsAbsMaterial* data);
        /**
         * @brief     写出基础属性数据
         * @param[i]  node 节点，data 材料派生类数据对象
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-24
         */
        bool writeBasicAttribute(rapidxml::xml_node<char>* node, Acoustics::FITKAcousticsAbsMaterial* data);
    };
        
    Register2FITKIOAdaptorFactory(VAOneXML, Materials, VAOneXMLAdaptorMaterials)
}

#endif // VAONEXMLADAPTORMATERIALS_H
